<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<title>管理课程</title>
<link rel="stylesheet" type="text/css" href="Assets/css/reset.css"/>
<script type="text/javascript" src="Assets/js/jquery-1.8.3.min.js"></script>
<link rel="stylesheet" type="text/css" href="Assets/plugins/FlexSlider/flexslider.css">
<script type="text/javascript" src="Assets/plugins/FlexSlider/jquery.flexslider.js"></script>
<script type="text/javascript" src="Assets/js/main.js"></script>


<link rel="stylesheet" type="text/css" href="Assets/css/thems.css">

<link rel="stylesheet" type="text/css" href="Assets/css/responsive.css">
<!-- -------------------------------------------------- -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>

<body>
<!--头部-->
<div class="head clearfix">
    <div class="logo"><a href=""><img src="Assets/images/logo.jpg" alt="信本财富"/></a></div>
    <div class="head_r">
    	<div class="lang">
        	<a href="">中文</a>|
        </div>
          <ul class="nav clearfix">
            <li class="now"><a href="index.html">首页</a></li>
            <li><a href="product.html">课程管理</a></li>
            <li><a href="vip.html">会员管理</a></li>
            <li><a href="sig_in.html">签到管理</a></li>
            <li><a href="custom-made.html">定制会员卡</a></li>
            <li><a href="subbranch.html">场馆管理</a></li>
            <li><a href="staff.html">员工管理</a></li>
        </ul>
        <div class="nav_m">
            <span class="n_icon">&nbsp;</span>
            <ul>
                <li><a href="index.html">首页</a></li>
                <li><a href="about.html">关于信本</a></li>
                <li><a href="news.html">信本动态</a></li>
                <li class="now"><a href="product.html">信本业务</a></li>
                <li><a href="#">信本学院</a></li>
                <li><a href="#">社会责任</a></li>
                <li><a href="#">联系我们</a></li>
            </ul>
        </div>
    </div>
</div>
<!--头部-->
<!--幻灯片-->
<div class="banner">
	<div class="slider">
        <div class="flexslider">
          <ul class="slides">
            <li>
                <a href=""><img src="Assets/upload/banner.jpg" alt="" /></a>
            </li>
            <li>
                <a href=""><img src="Assets/upload/banner_a.jpg" alt="" /></a>
            </li>
            <li>
                <a href=""><img src="Assets/upload/banner_b.jpg" alt="" /></a>
            </li>
            <li>
                <a href=""><img src="Assets/upload/banner_c.jpg" alt="" /></a>
            </li>
            <li>
                <a href=""><img src="Assets/upload/banner_d.jpg" alt="" /></a>
            </li>
          </ul>
        </div>
    </div>
</div>
<!--幻灯片-->
<div class="scd clearfix">
	<div class="scd_l">
    	<div class="title"><span>添加课程</span></div>
        <ul class="s_nav">
            <li><a href="product.html"><em>返回</em></a></li>
        </ul>
    </div>
    <div class="scd_r">
    	<div class="s_title">

            <div class="pst">
            	当前位置：
                <a href="">首页</a>>
                <a href="">课程管理</a>>
                <a href="">添加</a>>
            </div>
        </div>
        <div class="scd_m">
        	<div class="pro_d">


    <div class="form-group">
        <label for="name">课程名称</label>
        <input type="text" class="form-control" id="name"
               placeholder="请输入名称">
    </div>
    <div class="form-group">
        <label for="name">卡路里数</label>
        <input type="text" class="form-control" id="addcalorie"
               placeholder="请输入名称">
    </div>

    <div class="form-group">
    <label for="name">课程类型</label>
     <select name="" id="addType">
        <option value="团课">团课</option>
        <option value="私教">私教</option>
      </select>
        </div>
 <div class="form-group">
    <label for="name">课程难度</label>
     <select name="" id="addGrade">
        <option value="5">五星</option>
        <option value="4">四星</option>
        <option value="3">三星</option>
        <option value="2">二星</option>
        <option value="1">一星</option>
      </select>
</div>

 <div class="form-group">
 <label for="name">课程简介 </label>
 <textarea name="文本域名称" rows="行教" cols="列数" id="addIntro">
 </textarea>


</div>


    <div class="form-group">

        <label for="inputfile">图片选择</label>

        <form method="post" id="file1" enctype="multipart/form-data">
        <input type="file" id="inputfile" name="file">
        </form>

    </div>
     <img src="" id="img1" width="400px" height="300px">

    <button class="btn btn-default" id="addconfirm">提交</button>



            </div>
        </div>
    </div>
</div>

</body>
</html>
<script>
    var name = $("#name").val();

    console.log(name+"==============");

    var addGrade = $("#addGrade").val();

    $("#addGrade").change(function () {
        addGrade = $("#addGrade").val()

    });

    var addType= $("#addType").val()
       $("#addType").change(function () {
           addType = $("#addType").val()

        });


$("#addconfirm").click(function () {
    var name = $("#name").val();
    console.log(name+"==============课程名称");
    var addcalorie = $("#addcalorie").val()
    console.log(addcalorie+"==============卡路里");
    console.log(addGrade+"=============课程难度");
    console.log(addType+"=============私教还是团练");
    var addIntro = $("#addIntro").val();
    console.log(addIntro+"=============课程简介");

    console.log(imgPWT+"=============图片");
    var path = "/" + location.pathname.split("/")[1];

    $.get(path+"/addCurriculum",{"name":name,"addcalorie":addcalorie,"addGrade":addGrade,"addType":addType,"addIntro":addIntro,"imgPWT":imgPWT},function (list) {
        var li= eval(list);
        console.log(li+"===============");
        if (li){

            window.location.href="product.html"

        } else {
            alert("上传信息失败")

        }


    },"json");



});


    // $("#addconfirm").click(function () {
    //     console.log(
    //
    //         $("#addcalorie").val()
    //     $("#addType").val()
    //     $("#addType").change(function () {
    //         $("#addType").val()
    //
    //     })
    //
    //     $("#addGrade").val()
    //     $("#addGrade").change(function () {
    //         $("#addGrade").val()
    //
    //     })
    //
    //
    //     $("#addIntro").val()
    //
    //     // $("#name").val();
    //
    //
    //
    // )
    //
    //
    // })
    // $("#addconfirm1").click(function () {
    //
    // })

    //静态获取本地文件路径


</script>


<script type="text/javascript">
var imgPWT;


    $(function(){ $("#inputfile").change(function () {
        var path = "/" + location.pathname.split("/")[1];
        /*  var data  =  new FormData($("#file1")[0]);
          console.log(data+"==============");*/

        var formData = new FormData($('#file1')[0]);
        console.log(FormData);

        $.ajax({
            type: "post",
            url:path+"/FileImg",
            data: formData,
            cache: false,
            processData: false,
            contentType: false,
            beforeSend:function(){

            },
            success: function(msg){
                alert( "Data Saved: " + msg );
                var s = eval(msg);
                imgPWT =s;


                var paths= path+"/"+s;
                console.log(path+s+"==============");
                $("#img1").attr("src",paths);
            },
            error:function(){

            }
        });



        });

    });

</script>